########################################################################
# PLACE LIST CREATIONS HERE #
########################################################################
stage_list = ["moon", "mars", "jupiter", "pluto", "space", "city"]
head_list = ["head1", "head2", "head3", "head4", "head5", "head6"]
body_list = ["middle1", "middle2", "middle3", "middle4", "middle5", "middle6"]
legs_list = ["legs1", "legs2", "legs3", "legs4", "legs5", "legs6"]
########################################################################
# PLACE ALL OTHER CODE BELOW THIS #
########################################################################
stage_image = stage_list[1]
stage.set_background(stage_image)
random_head = random.randint(0, 5)
head_image = head_list[random_head]
# sprite = codesters.Sprite("image", x, y)
head = codesters.Sprite(head_image, 0, 83)
random_body = random.randint(0, 5)
body_image = body_list[random_body]
# sprite = codesters.Sprite("image", x, y)
body = codesters.Sprite(body_image, 0, 0)
legs_index = int(head.ask("Choose an index between 0 and 5."))
t = codesters.Teacher()
try:
tval1 = t.find_text("legs_image")[0][1].replace(' ', '')
except:
tval1 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == 'legs_image=legs_list[legs_index]', "Great job!")
t1.add_failure(tval1 == "DNE", "Did you use Get Value at Index and change the name to legs_image?")
t1.add_failure('legs_list' not in tval1, "Did you change the list name, outside the brackets, to legs_list?")
t1.add_failure('[legs_list]' in tval1, "Oops! Make sure your list name is outside the brackets and your index is inside.")
t1.add_failure('[legs_index]' not in tval1, "Did you change the index in your command to legs_index?")
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)